//
//  HomeViewModel.m
//  hello The traveler
//
//  Created by 贾帅 on 16/3/20.
//  Copyright © 2016年 hl. All rights reserved.
//

#import "HomeViewModel.h"
#import "MJExtension.h"
#import "HeFocus.h"


@implementation HomeViewModel

+ (instancetype)sharedHomeViewModel {

    static HomeViewModel *_instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[HomeViewModel alloc] init];
    });
    return _instance;
}


- (NSArray *)heFocus {
    
    

    if (!_heFocus) {
        _heFocus = [NSArray array];
        
        NSString *file = [[NSBundle mainBundle] pathForResource:@"focus.json" ofType:nil];
        
        NSData *data = [NSData dataWithContentsOfFile:file];
        
        
    

        NSDictionary *arr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        
        
        NSDictionary *dict = arr[@"data"];
                
       
          NSMutableArray *arr1 = [NSMutableArray array];

        
            for (NSDictionary *dic in dict) {
                
                HeFocus *model = [HeFocus focusWithDict:dic];
                
                
                [arr1 addObject:model];
                
//            }
             _heFocus = arr1;

        }
        
//        NSLog(@"%@",_heFocus);
        
        
    }
    return _heFocus;
}





@end
